﻿<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%@page
	import="com.baoming.domain.Properties"%><%@page
	import="com.baoming.domain.Singup"%>
<%String path = request.getContextPath();String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";%><%@taglib
	prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><%@taglib
	prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%><!DOCTYPE html>
<html lang="zh-cn">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="viewport"
			content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>在线报名</title>
		<link href="<%=basePath%>bootstrap/css/bootstrap.min.css"
			rel="stylesheet">
		<!--[if lt IE 9]><scriptsrc="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script><script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script><![endif]-->
	</head>
	<body><jsp:include page="pg_header.jsp"></jsp:include><div
			class="container-fluid">
			<img width="100%" height="auto" src="${singup.picPath }"
				class="header-image" alt="">
			<div class="row">
				<div class="col-sm-8 blog-main">
					<div class="blog-post">
						<h2 class="blog-post-title">
							${singup.title }
						</h2>
						${singup.content }
						<hr>
					</div>
					<form class="form-horizontal"
						action="<%=basePath %>page/execution.do" method="post"
						id="contact-form" role="form">
						<input type="hidden" name="singupId" value="${singup.id }">
						<c:set value="0" var="submit"></c:set>
						<c:forEach items="${props}" var="prop">
							<c:set value="1" var="submit"></c:set>
							<div class="form-group">
								<label for="inputEmail3" class="col-sm-2 control-label">
									<c:choose>
										<c:when test="${empty prop.alias}"> ${prop.value }</c:when>
										<c:otherwise>${prop.alias }</c:otherwise>
									</c:choose>
								</label>
								<div class="col-sm-${prop.size }">
									<c:choose>
										<c:when test="${prop.type == 'text'}">
											<c:choose>
												<c:when test="${!empty prop.xmlValue}">
													<select name="${prop.name }" id="select_opt_${prop.name }"
														class="form-control">
														<option value="">
															<c:choose>
																<c:when test="${empty prop.alias}">${prop.value } </c:when>
																<c:otherwise> ${prop.alias } </c:otherwise>
															</c:choose>
														</option>
														<c:forEach items="${prop.xmlValue}" var="pvalue">
															<option value="${pvalue }">
																${pvalue }
															</option>
														</c:forEach>
													</select>
												</c:when>
												<c:otherwise>
													<input name="${prop.name }" type="text"
														class="form-control" placeholder="${prop.alias }">
												</c:otherwise>
											</c:choose>
										</c:when>
										<c:when test="${prop.type == 'area'}">
											<textarea class="form-control" name="${prop.name }" rows="2"
												placeholder="${prop.alias }"></textarea>
										</c:when>
										<c:when test="${prop.type == 'file'}">
											<input class="form-control" type="text"
												id="chooseresult_${prop.name }" readonly
												name="${prop.name }">
										</c:when>
									</c:choose>
								</div>
							</div>
						</c:forEach>
						<c:if test="${!empty singup.code && submit == 1}">
							<div class="form-group">
								<label class="col-sm-2 control-label">
									标识码
								</label>
								<div class="col-sm-3">
									<input name="code2" type="text" class="form-control"
										placeholder="标识码">
								</div>
							</div>
						</c:if>
						<c:if test="${submit == 1}">
							<div class="form-group">
								<label class="col-sm-2 control-label">
									验证码
								</label>
								<div class="col-sm-5">
									<input name="code" type="text" class="form-control"
										placeholder="${prop.alias }">
								</div>
								<div class="col-sm-3">
									<img src="gloabl_code.jpg?timestamp=1395668265513"
										style="cursor: pointer; float: right;" id="checkNumberImage"
										onclick="RefCode()" alt="">
								</div>
							</div>
							<div class="form-group">
								<div class="col-sm-offset-2 col-sm-10">
									<button type="submit" class="btn btn-primary">
										提交
									</button>
								</div>
							</div>
						</c:if>
					</form>
				</div>
				<jsp:include page="singup_left.jsp"></jsp:include>
			</div>
		</div>
		<jsp:include page="singup_footer.jsp"></jsp:include>
		<script src="bootstrap/js/jquery.js"></script>
		<script type="text/javascript"> 
			function RefCode() { 
				var checkNumberImage = document.getElementById("checkNumberImage"); 
				checkNumberImage.src = "gloabl_code.jpg?timestamp="+ new Date().getTime(); 
			} 
			$(document).ready(function() {
				$('#contact-form').validate( { 
					rules : { <%  List<Properties> propList = (List<Properties>)request.getAttribute("props") ;  
						for(int i = 0 ; i < propList.size() ; i ++){ 
							Properties prop = propList.get(i) ; %> 
							<%=prop.getName() %> : {  
							maxlength : <%=prop.getSize()*4 %>, 
							required : <%= prop.getRequested()==1?"true":"false" %> }, <%  }  
							Singup singup = (Singup)request.getAttribute("singup") ;  
							if(singup.getCode() != null && singup.getCode().length() > 0){  
							int length = singup.getCode().length() ;  %>  code2 : { minlength : <%=length %>, maxlength : <%=length %>, 
							required : true }, <%  
							} %> code : { 
							minlength : 3, maxlength : 3, 
							required : true } 
							}, 
							highlight : function(element) { 
							$(element).closest('.control-group') .removeClass('success').addClass( 'error'); }, 
							success : function(element) { 
							element.text('OK!').addClass('valid').closest( '.control-group').removeClass('error') .addClass('success'); 
							}  
							}); 
							}); </script>
	</body>
</html>

